package com.rmondjone.view

import android.animation.ObjectAnimator
import android.content.Context
import android.util.AttributeSet
import android.view.animation.LinearInterpolator
import com.rmondjone.androidcamerademo.R

/**
 * copyright：
 * @author：anthui creation date： .
 * @since: 1.0.0
 * @describe:
 */
class LoadView(context: Context, attrs: AttributeSet?) : androidx.appcompat.widget.AppCompatImageView(context, attrs) {
    var animatior: ObjectAnimator? = null

    init {
        background = resources.getDrawable(R.mipmap.bg_load2)
        startAnimator()
    }

    fun startAnimator() {
        if (animatior != null) {
            return
        }

        //360 旋转
        animatior = ObjectAnimator.ofFloat(this, "rotation", 360f).apply {
            //匀速滑动
            interpolator = LinearInterpolator()
            duration = 3000
            repeatCount = -1
            start()
        }
    }

    fun stopAnimator() {
//        animatior?.cancel()
//        animatior = null
//        visibility = View.GONE
    }

}